home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 09 / 3 / DISK0932.ZIP / SOURCE.EXE / arc / EXEC.PAS < prev    next >
Pascal/Delphi Source File  |  1989-02-16  |  3KB  |  94 lines

  1. {        2/16/89:  My thanks to the Turbo Users Group (T.U.G.) & to
  2.     Bela Lubkin of Borland, for releasing to Public Domain Exec.pas.  This
  3.     modified version is pared down for Labcoat to call Qchart.exe.  If you
  4.     would like to know more about Exec.pas, contact me or, better yet,
  5.     join T.U.G.:  $24.00/yr   -   P.O. Box 1510 - Poulsbo, WA 98370         
  6.           If you program in Pascal, you'll find T.U.G.'s newsletters &
  7.         libraries to be a real help, especially now, since Borland has axed
  8.     Turbo Technix.  T.U.G.'s interests also serve users of All the other
  9.         Turbo language compilers - not just Pascal.  }
  10.  
  11. program exec;
  12.  
  13. Type
  14.   Str66=String[66];
  15.   Str255=String[255];
  16.  
  17. Function SubProcess(CommandLine: Str255): Integer;
  18.  
  19.   Var
  20.     Regs: Record Case Integer Of
  21.             1: (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: Integer);
  22.             2: (AL,AH,BL,BH,CL,CH,DL,DH: Byte);
  23.           End;
  24.     FCB1,FCB2: Array [0..36] Of Byte;
  25.     PathName: Str66;
  26.     CommandTail: Str255;
  27.     ParmTable: Record
  28.                  EnvSeg: Integer;
  29.                  ComLin: ^Integer;
  30.                  FCB1Pr: ^Integer;
  31.                  FCB2Pr: ^Integer;
  32.                End;
  33.  
  34.   Begin
  35.     If Pos(' ',CommandLine)=0 Then
  36.      Begin
  37.       PathName:=CommandLine+#0;
  38.       CommandTail:=^M;
  39.      End
  40.     Else
  41.      Begin
  42.       PathName:=Copy(CommandLine,1,Pos(' ',CommandLine)-1)+#0;
  43.       CommandTail:=Copy(CommandLine,Pos(' ',CommandLine),255)+^M;
  44.      End;
  45.     CommandTail[0]:=Pred(CommandTail[0]);
  46.     With Regs Do
  47.      Begin
  48.       FillChar(FCB1,Sizeof(FCB1),0);
  49.       AX:=$2901;
  50.       DS:=Seg(CommandTail[1]);
  51.       SI:=Ofs(CommandTail[1]);
  52.       ES:=Seg(FCB1);
  53.       DI:=Ofs(FCB1);
  54.       MsDos(Regs); { Create FCB 1 }
  55.       FillChar(FCB2,Sizeof(FCB2),0);
  56.       AX:=$2901;
  57.       ES:=Seg(FCB2);
  58.       DI:=Ofs(FCB2);
  59.       MsDos(Regs); { Create FCB 1 }
  60.       ES:=CSeg;
  61.       BX:=SSeg-CSeg+MemW[CSeg:MemW[CSeg:$0101]+$112];
  62.       AH:=$4A;
  63.       MsDos(Regs); { Deallocate unused memory }
  64.       DS:=Seg(PathName[1]);
  65.       DX:=Ofs(PathName[1]);
  66.       With ParmTable Do
  67.        Begin
  68.         EnvSeg:=MemW[CSeg:$002C];
  69.         ComLin:=Addr(CommandTail);
  70.         FCB1Pr:=Addr(FCB1);
  71.         FCB2Pr:=Addr(FCB2);
  72.        End;
  73.       ES:=Seg(ParmTable);
  74.       BX:=Ofs(ParmTable);
  75.       AX:=$4B00;
  76.       MsDos(Regs); { Call subprocess }
  77.       If (Flags And 1)<>0 Then SubProcess:=AX
  78.       Else SubProcess:=0;
  79.      End;
  80.   End;
  81.  
  82.  
  83.  
  84. Var Command: Str255;
  85.     I: Integer;
  86.  
  87. Begin
  88.     Command := 'qchart.exe';
  89.     If Command<>'' Then
  90.      Begin
  91.       I:=SubProcess(Command);
  92.      End;
  93. End.
  94.